﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;

namespace Snap.Api.Imgur
{
    public class ImgurApiResponse : ApiResponseBase
    {
        [JsonProperty("upload")]
        private Upload UploadClass { get; set; }

        /// <summary>
        /// Returns the direct link to the uploaded image.
        /// </summary>
        public override string Link
        {
            get { return this.UploadClass.LinksClass.Original; }
        }

        public ImgurApiResponse()
        {
            UploadClass = new Upload();
        }

        private class Upload
        {
            [JsonProperty("image")]
            public Image ImageClass { get; set; }

            [JsonProperty("links")]
            public Links LinksClass { get; set; }

            public Upload()
            {
                ImageClass = new Image();
                LinksClass = new Links();
            }

            public class Image
            {
                [JsonProperty("name")]
                public String Name { get; set; }

                [JsonProperty("title")]
                public String Title { get; set; }

                [JsonProperty("caption")]
                public String Caption { get; set; }

                [JsonProperty("hash")]
                public String Hash { get; set; }

                [JsonProperty("deletehash")]
                public String DeleteHash { get; set; }

                [JsonProperty("datetime")]
                public DateTime DateTime { get; set; }

                [JsonProperty("type")]
                public String Type { get; set; }

                [JsonProperty("animated")]
                public bool IsAnimated { get; set; }

                [JsonProperty("width")]
                public int Width { get; set; }

                [JsonProperty("height")]
                public int Height { get; set; }

                [JsonProperty("size")]
                public int Size { get; set; }

                [JsonProperty("views")]
                public int NumberOfViews { get; set; }

                [JsonProperty("bandwith")]
                public int Bandwith { get; set; }
            }

            public class Links
            {
                [JsonProperty("original")]
                public String Original { get; set; }

                [JsonProperty("imgur_page")]
                public String ImgurPage { get; set; }

                [JsonProperty("delete_page")]
                public String DeletionPage { get; set; }

                [JsonProperty("small_square")]
                public String Thumbnail { get; set; }

                [JsonProperty("large_thumbnail")]
                public String LargeThumbnail { get; set; }
            }
        }
    }
}
